<script setup lang="ts">
import { ref } from 'vue';
import { userUserStore } from '@/store/user';
import { storeToRefs } from 'pinia';

defineProps<{ msg: string }>();

const count = ref(0);
const userStore = userUserStore();
//使用storeToRefs 结构 会保持响应式
// const { name } = storeToRefs(userStore)
const changeName = () => {
  userStore.name = "我改名字了"
}
</script>

<template>
  <h1>{{ msg }}</h1>

  <div class="card">
    <button type="button" @click="count++">count is {{ count }}</button>
    <button type="button">name is {{ userStore.name }}</button>
    <button type="button">name is {{ userStore.getNewName }}</button>
    <button type="button">name is {{ userStore.getAddAge(80) }}</button>
    <p>
      Edit
      <code>components/HelloWorld.vue</code> to test HMR
    </p>
  </div>
  <button @click="changeName">修改store姓名</button>
</template>

<style scoped>
.read-the-docs {
  color: #888;
}
</style>
